package com.kolakcc.loljclient.model;

import com.gvaneyck.rtmp.TypedObject;

public class CustomGamePlayer {
	public TypedObject internalTypedObject;
	private int modeledAfterDataVersion = 1;

	public int accountID;
	public String botDifficulty;
	public String summonerInternalName;
	public int profileIconID;
	public int summonerID;
	public int badges; // has value 8, bitwise comparison?
	public int dataVersion;
	public int pickTurn;
	public boolean inSync;
	public String summonerName;
	public int pickMode;
	public String originalPlatformID;

	// No clue what these are
	public Object timeAddedToQueue; // is this the queue dodge penalty?
	public int index;
	public int queueRating; // seems to be 0 for custom games?
	public int originalAccountNumber; // Is this from before a server change or
										// something?
	public Object minor; // always false?
	public Object locale; // seems to always be null...
	public int lastSelectedSkinIndex; // always 0?
	public boolean teamOwner; // always false?
	public Object futureData; // always null?
	public Object teamParticipantID; // always null?
	
	public PlayerChampionSelection championSelection;

	public CustomGamePlayer(TypedObject data) {
		this.internalTypedObject = data;
		this.timeAddedToQueue = data.get("timeAddedToQueue");
		this.index = data.getInt("index");
		this.queueRating = data.getInt("queueRating");
		this.accountID = data.getInt("accountId");
		this.botDifficulty = data.getString("botDifficulty");
		this.originalAccountNumber = data.getInt("originalAccountNumber");
		this.summonerInternalName = data.getString("summonerInternalName");
		this.minor = data.getBool("minor");
		this.locale = data.get("locale");
		this.lastSelectedSkinIndex = data.getInt("lastSelectedSkinIndex");
		this.profileIconID = data.getInt("profileIconId");
		this.teamOwner = data.getBool("teamOwner");
		this.futureData = data.get("futureData");
		this.summonerID = data.getInt("summonerId");
		this.badges = data.getInt("badges");
		this.dataVersion = data.getInt("dataVersion");
		this.pickTurn = data.getInt("pickTurn");
		this.inSync = data.getBool("clientInSynch");
		this.summonerName = data.getString("summonerName");
		this.pickMode = data.getInt("pickMode");
		this.originalPlatformID = data.getString("originalPlatformId");
		this.teamParticipantID = data.get("teamParticipantId");

		if (this.modeledAfterDataVersion != this.dataVersion) {
			System.out
					.println("The version of this data does not match the version that is modelled. ("
							+ this.internalTypedObject.type + ")");
			System.out.println(this.internalTypedObject);
		}
	}

	public boolean isBot() {
		return (this.botDifficulty == "NONE");
	}
	public String toString() {
		if ((championSelection != null) && (championSelection.championID != 0)) {
			System.out.println(championSelection);
			return this.summonerName + " (" + Champion.getChampionFromID(this.championSelection.championID).getDisplayName() + ")";
		}
		return this.summonerName;
	}
}
